package
{
	import com.dougmccune.containers.CoverFlowContainer;
	
	import mx.collections.ArrayCollection;
	import mx.events.CollectionEvent;
	public class FlashIslandCoverFlow extends CoverFlowContainer
	{
		private var _dataProvider:ArrayCollection;
		public function FlashIslandCoverFlow()
		{
			super();
			this.reflectionEnabled = true;
		}
		
		public function set dataProvider(dataProvider:ArrayCollection):void
		{
			_dataProvider = dataProvider;
			for each(var o:Object in _dataProvider){
				addItem(o);
			}
			_dataProvider.addEventListener(CollectionEvent.COLLECTION_CHANGE, updateItems);		
			
		}
		
		public function get dataProvider():ArrayCollection
		{
			return _dataProvider;
		}
		private function addItem(o:Object):void{
			var img:ImageWIthCaption;
			img = new ImageWIthCaption();
			img.caption = o["caption"];
			img.imageSource = o["image"];
			addChild(img);
			
		}
		private function updateItems(event:CollectionEvent):void
		{
			if(event.kind == "add"){
				for each(var o:Object in event.items){
					addItem(o);
				}
			}
		}
	}
}